<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <title>医生排班</title>
    <link th:href="@{/localcss/crmlist.css}" href="../static/localcss/crmlist.css" rel="stylesheet">
</head>
<body>
<div layout:fragment="content">
    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>
                            查询条件 <i class="fa fa-user"></i>
                        </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form method="post" action="/paiban/paibanPage" th:action="@{/paiban/paibanPage}">
                            <input type="hidden" name="pageIndex" th:value="1"/>
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">医生姓名</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="doctorName" type="text"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <button type="button" th:onclick="|byIdSel()|"  class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询</button>
                                </li>
                            </ul>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_content">
                        <p class="text-muted font-13 m-b-30"></p>
                        <div id="datatable-responsive_wrapper"
                             class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <div class="col-sm-12">
                                    <table id="datatable-responsive"
                                           class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                           cellspacing="0" width="100%" role="grid"
                                           aria-describedby="datatable-responsive_info" style="width: 100%;">
                                        <thead>
                                        <tr role="row">
                                            <th class="sorting_asc" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="First name: activate to sort column descending"
                                                aria-sort="ascending">编号
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                姓名
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期一
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期二
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期三
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期四
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期五
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期六
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                星期日
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                操作
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody id="x-show">
                                        <tr th:each="paiban : ${paiban}" role="row" class="odd" >
                                            <td tabindex="0" class="sorting_1" th:text="${paiban.doctorId}">paiId</td>
                                            <td th:text="${paiban.doctorName}"></td>
                                            <td th:text="${paiban.one}"></td>
                                            <td th:text="${paiban.two}"></td>
                                            <td th:text="${paiban.three}"></td>
                                            <td th:text="${paiban.four}"></td>
                                            <td th:text="${paiban.five}"></td>
                                            <td th:text="${paiban.six}"></td>
                                            <td th:text="${paiban.seven}"></td>
                                            <td>
                                                <div class="btn-group">
                                                    <button type="button" class="btn btn-danger">点击操作</button>
                                                    <button type="button" class="btn btn-danger dropdown-toggle"
                                                            data-toggle="dropdown" aria-expanded="false">
                                                        <span class="caret"></span>
                                                        <span class="sr-only">Toggle Dropdown</span>
                                                    </button>
                                                    <ul class="dropdown-menu" role="menu">
                                                        <li><a class="editInfo" href="#" th:href="@{'/paiban/edit?doctorId='+${paiban.doctorId}}"
                                                               data-toggle="tooltip" data-placement="top" title=""
                                                               data-original-title="修改">修改</a></li>
                                                        <li><a class="delInfo" id="del" href="#"
                                                               data-toggle="tooltip" data-placement="top" title=""
                                                               data-original-title="删除" th:onclick="|doDel(this,${paiban.doctorId})|">删除</a></li>
                                                    </ul>
                                                </div>
                                            </td>

                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</body>
<script layout:fragment="js">
    function byIdSel(){
        var doctorName=$("[name='doctorName']").val();
        $.ajax({
            type:"get",
            url:"byIdSerach",
            data:"doctorName="+doctorName,
            dataType:"json",
            success:function(data){
                alert("查询成功！");
                console.log(data);
                $("#x-show").html("");
                $(data).each(function(){
                    var str="<td><div class='btn-group'>"
                        +"<button type='button' class='btn btn-danger'>"
                        +"点击操作</button><button type='button' class='btn btn-danger dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>"
                        +"<span class='caret'></span><span class='sr-only'>Toggle Dropdown</span> </button><ul class='dropdown-menu' role='menu'>"
                        +"<li><a class='editInfo' href='/paiban/edit?doctorId="+this.doctorId+"' data-toggle='tooltip' data-placement='top'  data-original-title='编辑'>"
                        +"编辑</a></li><li><a class='delInfo' id='del' href='#' data-toggle='tooltip' data-placement='top' data-original-title='删除'"
                        +" onclick='doDel(this,"+this.doctorId+")'>删除</a></li></ul></div></td>";
                    var stc="<tr  role='row' class='odd ' >"
                        + "<td tabindex='0' class='sorting_1' >"+this.doctorId+"</td>"
                        +"<td>"+this.doctorName+"</td>"
                        +"<td >"+this.one+"</td>"
                        +"<td >"+this.two+"</td>"
                        +"<td >"+this.three+"</td>"
                        +"<td >"+this.four+"</td>"
                        +"<td >"+this.five+"</td>"
                        +"<td >"+this.six+"</td>"
                        +"<td >"+this.seven+"</td>" +str;
                    $("#x-show").append(stc);
                })

            }
        })
    }
    function doDel(obj,doctorId) {
        if (confirm("你确定需要删除该医生信息吗？")) {
            $.ajax({
                type: "get",
                url: "del",
                data: "doctorId=" + doctorId,
                dataType: "json",
                success: function (data) {
                    if (data.status=1) {//删除成功：移除删除行
                        alert("删除成功！");
                        $(obj).parents("tr").remove();
                    } else {
                        alert("对不起，删除失败！");
                    }
                },
                error: function (data) {
                    alert("对不起，删除失败!!！");
                }
            });
        }
    }

</script>
</html>